package com.vm.osm.business.util;

import com.google.common.collect.Maps;
import org.springframework.cglib.beans.BeanMap;

import java.util.Map;

/**
 * Created by chenzui on 2018/3/15.
 */
public class MapUtil {
    public static <T> Map<String, String> beanToMap(T bean) {
        Map<String, String> map = Maps.newHashMap();
        if (bean != null) {
            BeanMap beanMap = BeanMap.create(bean);
            for (Object key : beanMap.keySet()) {
                if(beanMap.get(key) != null){
                    map.put(key+"", beanMap.get(key).toString());
                }
            }
        }
        return map;
    }
}
